package com.fbd.apipassenger.service;

import com.fbd.apipassenger.remote.ServicePassengerUserClient;
import com.fbd.internalcommon.dto.ResponseResult;
import com.fbd.internalcommon.dto.TokenResult;
import com.fbd.internalcommon.dto.VerificationCodeDTO;
import com.fbd.internalcommon.util.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @Autowired
    private ServicePassengerUserClient servicePassengerUserClient;

    public ResponseResult getUserByAccessToken(String refreshToken){
        // 解析token，获取手机号
        TokenResult tokenResult = JwtUtils.pareToken(refreshToken);
        String phone = tokenResult.getPhone();
        // 用手机号查询用户信息
        ResponseResult user = servicePassengerUserClient.getUser(phone);
        return ResponseResult.success(user);
    }
}
